home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / glibc-1.09 / glibc-1 / glibc-1.09.1 / sysdeps / standalone / m68k / m68020 / start.S < prev   
Encoding:
Text File  |  1994-08-24  |  5.0 KB  |  156 lines

  1. /* Copyright (C) 1994 Free Software Foundation, Inc.
  2.    Contributed by Joel Sherrill (jsherril@redstone-emh2.army.mil),
  3.      On-Line Applications Research Corporation.
  4.  
  5. This file is part of the GNU C Library.
  6.  
  7. The GNU C Library is free software; you can redistribute it and/or
  8. modify it under the terms of the GNU Library General Public License as
  9. published by the Free Software Foundation; either version 2 of the
  10. License, or (at your option) any later version.
  11.  
  12. The GNU C Library is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15. Library General Public License for more details.
  16.  
  17. You should have received a copy of the GNU Library General Public
  18. License along with the GNU C Library; see the file COPYING.LIB.  If
  19. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  20. Cambridge, MA 02139, USA.  */
  21.  
  22. /*  entry.s
  23.  *
  24.  *  This file contains the entry point for the application.
  25.  *  The name of this entry point is compiler dependent.
  26.  *  It jumps to the BSP which is responsible for performing
  27.  *  all initialization.
  28.  */
  29.  
  30.         .text
  31.           .globl   start                        | Default entry point
  32.           .globl   _start                       | Default entry point
  33.           .globl   M68Kvec                      | Vector Table
  34.           .globl   _M68Kvec                     | Vector Table
  35.  
  36. start:
  37. _start:
  38. M68Kvec:                               | standard location for vectors
  39. _M68Kvec:                               | standard location for vectors
  40.         nop                             | for linkers with problem
  41.                                         |   using location zero as entry
  42.         jmp      around
  43.         .space   4088                   | to avoid initial intr stack
  44.                                         |   from 135BUG on MVME13? as entry
  45.                                         |   and start code at 0x4000
  46. around: 
  47.         move.w  %sr,initial_sr          | save initial values
  48.         movec   %isp,%a0
  49.         movel   %a0,initial_isp
  50.         movec   %usp,%a0
  51.         movel   %a0,initial_usp
  52.         movec   %msp,%a0
  53.         movel   %a0,initial_msp
  54.         oriw    #0x0700,%sr             | INTERRUPTS OFF!!!
  55.  
  56.         
  57.  
  58.         |
  59.         | zero out uninitialized data area
  60.         |
  61. zerobss:
  62.         moveal  #end,%a0                | find end of .bss 
  63.         moveal  #_bss_start,%a1         | find beginning of .bss 
  64.         movel   #0,%d0
  65.  
  66. loop:   movel   #0,%a1@+                | to zero out uninitialized
  67.         cmpal   %a0,%a1
  68.         jlt     loop                    | loop until _end reached 
  69.  
  70.         movel   #heap_size,__C_heap_size | set ___C_heap_size
  71.         movel   #heap_memory,__C_heap_start | set ___C_heap_start
  72.         moveal  #interrupt_stack_end,%a0 | set interrupt stack pointer
  73.         movec   %a0,%isp
  74.         moveal  #stack_end,%a0          | set master stack pointer
  75.         movec   %a0,%msp
  76.         moveal  #stack_end,%a6          | set base pointer
  77.         movw    #0x3000,%sr             | SUPV MODE,INTERRUPTS ON!!!
  78.  
  79. #ifdef NEED_UNDERSCORES
  80.         jsr     __Board_Initialize      | initialize the board 
  81. #else
  82.         jsr     _Board_Initialize       | initialize the board 
  83. #endif
  84.  
  85.         move.l  #0,%sp@-                | envp = NULL 
  86.         move.l  #0,%sp@-                | argv = NULL 
  87.         move.l  #0,%sp@-                | argc = NULL 
  88. #ifdef NEED_UNDERSCORES
  89.         jsr     ___libc_init            | initialize the library and
  90.                                         |   call main
  91. #else
  92.         jsr     __libc_init             | initialize the library and
  93.                                         |   call main
  94. #endif
  95.         add.l   #12,%sp
  96.  
  97.         move.l  #0,%sp@-                | argc = NULL 
  98.         jsr     __exit                  | call the Board specific exit
  99.         addq.l  #4,%sp
  100.  
  101.         move.l  initial_isp,%a0         | if __exit returns then we can
  102.         movec   %a0,%isp                |   restore the initial values
  103.         move.l  initial_usp,%a0
  104.         movec   %a0,%usp
  105.         move.l  initial_msp,%a0
  106.         movec   %a0,%msp
  107.         move.w  initial_sr,%sr
  108.         rts
  109.  
  110.  
  111.         .bss
  112.  
  113. /*
  114.  *  So initial stack registers and status register can be saved.
  115.  */
  116.  
  117. #define DECLARE_SPACE(_name,_space,_align) \
  118.           .globl   _name ; \
  119.           .align   _align ; \
  120. _name##:  .space _space
  121.  
  122. #define DECLARE_LABEL(_name) \
  123.           .globl   _name ; \
  124. _name##:  
  125.  
  126. #define DECLARE_PTR(_name) DECLARE_SPACE(_name,4,2)
  127. #define DECLARE_U32(_name) DECLARE_SPACE(_name,4,2)
  128. #define DECLARE_U16(_name) DECLARE_SPACE(_name,2,1)
  129.  
  130. DECLARE_U32(initial_isp)
  131. DECLARE_U32(initial_msp)
  132. DECLARE_U32(initial_usp)
  133. DECLARE_U16(initial_sr)
  134.  
  135. /*
  136.  *  Require environment stuff
  137.  */
  138.  
  139. DECLARE_LABEL(_environ)
  140. DECLARE_PTR(environ)
  141.  
  142. DECLARE_LABEL(_errno)
  143. DECLARE_U32(errno)
  144.  
  145. /*
  146.  *  Stack Size and Space
  147.  */
  148.  
  149.         .set stack_size, 0x20000
  150.  
  151. DECLARE_SPACE(stack_memory,stack_size,4)
  152. DECLARE_LABEL(stack_end)
  153.  
  154. DECLARE_SPACE(interrupt_stack_memory,0x1000,4)
  155. DECLARE_LABEL(interrupt_stack_end)
  156.